import { _decorator, Component, Node } from "cc";
import { Game } from "./Game/Game";
import { ResMgr } from "./Managers/ResMgr";
import { EventMgr } from "./Managers/EventMgr";
import { SoundMgr } from "./Managers/SoundMgr";
import { UIMgr } from "./Managers/UIMgr";

const { ccclass, property } = _decorator;

@ccclass("GameLanch")
export class GameLanch extends Component
{

  @property
  private isUsingNet: boolean = false;

  public static Instance: GameLanch = null;
  onLoad()
  {
    if (GameLanch.Instance === null)
    {
      GameLanch.Instance = this;
    }
    else
    {
      this.destroy();
      return;
    }

    // 初始化框架
    // this.node.addComponent(ResMgr);
    ResMgr.Instance.init();
    this.node.addComponent(EventMgr);
    this.node.addComponent(SoundMgr);
    this.node.addComponent(UIMgr);

    // 初始化游戏代码对象
    this.node.addComponent(Game);
  }

  start()
  {
    Game.Instance.gameStart();
  }
}
